<?php
	
class Admin_Model_TmpInbound extends Admin_Model_Db_TmpInbound
{
	public function fetchInboundCode($inbound_warehouse_group_code)
	{
		//lấy code mới nhất
		$code="XGC-".$inbound_warehouse_group_code."-";
		$this->fetchRowAllBase("inbound_code LIKE '%$code%'","inbound_id DESC",$entry);
		$newest_inbound_code=$entry->inbound_code;
		$from=strrpos($newest_inbound_code,"-")+1;
		$array_tmp=explode("-", $tmp);
		$no=substr($newest_inbound_code, $from,strlen($newest_inbound_code)-5-$from);
		$no=$no+1;
		
		//xu lí năm
		$year=date("Y");
		
		//trả ra mã code
		$inbound_code=$code.$no."/".$year;
		return $inbound_code;
	}
	public function __construct(array $options = null)
	{
		$this->getDbTable()->_primary = 'inbound_id';
		return parent::__construct($options);
	}	
}